Date.prototype.format = function(format){
var o = {
"M+" : this.getMonth()+1, //month
"d+" : this.getDate(), //day
"h+" : this.getHours(), //hour
"m+" : this.getMinutes(), //minute
"s+" : this.getSeconds(), //second
"q+" : Math.floor((this.getMonth()+3)/3), //quarter
"S" : this.getMilliseconds() //millisecond
}

if(/(y+)/.test(format)) {
format = format.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
}

for(var k in o) {
if(new RegExp("("+ k +")").test(format)) {
format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length));
}
}
return format;
}







function pageList(list,restype){
	//分页
	$(".page").empty();
	var fullListSize = list.totalRecord;
 	var pageNumber = list.currPage;
 	var totalPage=list.totalPage;
 	if(fullListSize!=undefined && fullListSize!=null && fullListSize>0){
 		var start = 1;
			var end = totalPage;
			if(totalPage > 5 && pageNumber != 1) {
				if((totalPage-pageNumber)<3){
					start = pageNumber - (5 -(totalPage-pageNumber) -1);
				}else{
					start =  pageNumber -1;
				}
			} 
			if((totalPage-3)>pageNumber){
				if(pageNumber == 1) {
					end = 5;
				} else {
 				end = pageNumber + 3;
				}
			}
			var prePage = pageNumber - 1 < 1 ? 1 : pageNumber - 1;
			var nextPage = pageNumber + 1 > totalPage ? totalPage : pageNumber + 1;
			$(".page").append('<a href="javascript:goToPage(1,'+restype+')">首页</a> ');
			$(".page").append('<a href="javascript:goToPage('+prePage+','+restype+')">上一页</a> ');
			for(var i=start;i<=end;i++){
 			if(i == pageNumber){
 				if(i < 5) {
 					$str = $('<a class="intro" href="javascript:goToPage('+i+','+restype+')">'+i+'</a> ');
 				} else {
 					$str = $('<a class="intro" href="javascript:goToPage('+i+','+restype+')">'+i+'</a> ');
 				}
	 		}else{
	 			if(i < 5) {
	 				$str = $('<a href="javascript:goToPage('+i+','+restype+')">'+i+'</a> ');
	 			} else {
	 				$str = $('<a href="javascript:goToPage('+i+','+restype+')">'+i+'</a> ');
	 			}
	 		}
				$(".page").append($str);
		}
			$(".page").append(' <a href="javascript:goToPage('+nextPage+','+restype+')">下一页</a> ');
			$(".page").append('<a href="javascript:goToPage('+totalPage+','+restype+')">末页</a>');
 	}
}





